<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
*{ margin:0; padding:0;}
#box{ width:150px; height:150px; background:red; position:absolute;}
</style>
<script type="text/javascript" src="js/comet.js"></script>
</head>

<body>
<div id="box"></div>
<img id="sender" style="display:none;" src="" />
<script type="text/javascript">
var local = true, x = 0, y = 0;


function sendPoint(x,y,u){
	document.getElementById('sender').src = 'receive.php?x='+x+'&y='+y+'&username='+u+'&r='+(new Date);
}

(function(){
	//var timer = setInterval("sendPoint(x,y,'Javin')",100);
})();
//-----------Drag----------------
function Drag(o){
	this.locked = false;
	this.localX = this.localY = 0;
	this.index = 0;
	var _this = this;
	o.onmousedown = function(event){
		_this.locked = true;
		local = false;
		var e = event || window.event;
		_this.localX = e.offsetX || e.layerX;
		_this.localY = e.offsetY || e.layerY;
		_this.index = this.style.zIndex;
		this.style.zIndex = 99999;
		stopDefault(e);
	};
	o.onmousemove = function(event){
		if(!_this.locked) return false;
		var e = event || window.event;
		var mouse = {};
		mouse.x = e.clientX;
		mouse.y = e.clientY;
		
		var left = mouse.x - _this.localX;
		var top = mouse.y - _this.localY;
		this.style.left = left +'px';
		this.style.top = top + 'px';
		x = left;
		y = top;
	};
	o.onmouseup = function(){
		_this.locked = false;
		local = true;
		this.style.zIndex = _this.index;
	};
}

function stopBubble(e){
	if(e && e.stopPropagation){
		e.stopPropagation();
	}else{
		window.event.cancelBubble = true;
	}
}

function stopDefault(e){
	if(e && e.preventDefault){
		e.preventDefault();
	}else{
		window.event.returnValue = false;
	}
}

new Drag(document.getElementById('box'));
</script>

<!--<iframe id="proxy" style="display:none;" src="cometSev.php"></iframe>-->
<script type="text/javascript">
window.onload = comet.init;
window.onunload = comet.onUnload;
</script>
</body>
</html>
